home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / DIALER.CMD < prev    next >
OS/2 REXX Batch file  |  1992-11-14  |  22KB  |  865 lines

  1. ; ----- COM-AND Multi-dialer script
  2. ;
  3. ;    This script opens a window and asks for up to 10 dialing directory
  4. ;    numbers (with or without long distance prefix).  As numbers are
  5. ;    selected, the dialing directory values are displayed (and the dialing
  6. ;    directory may be cycled through, searching).
  7. ;
  8. ;    When dialing is initiated, the current selections are saved to a file
  9. ;    on the current drive/subdirectory named DIALER.DAT.  If a connection
  10. ;    is made, the DIALER.DAT is updated to eliminate the connection just
  11. ;    made from the list.
  12. ;
  13. ;    If a script is associated with the dialing directory entry to which
  14. ;    connection is made, it is EXECUTED just as if from Alt-D.
  15. ;
  16. ;    R.McG, commenced 10/88
  17. ;           updated      3/89 (CLOG start and hit, and add alarm)
  18. ;           updated     10/92 (Fixes; changed for area code strip, dd changes)
  19. ; ----- Usages -----------------
  20. ;    S19 -----> Parameter string read/written to the .DAT file
  21. ;    N8 ------> Saved cursor row #
  22. ;    N9 ------> Saved cursor col #
  23. ;    N10-N19 -> Working storage for the screen display (LD# and DD#)
  24. ; ------------------------------
  25. ;    Initialization
  26. ;
  27. ;* TRACE ON
  28.    CLEAR
  29.    CURSOR N8,N9             ; Save cursor on entry
  30.    ON ESCAPE GOSUB Exit         ; SAVE is performed in Window
  31.    LEGEND " Multi-dialer pop-up"
  32.    SET TTHRU OFF            ; Disallow typeahead
  33.    CLOG "* Dialer multi-dialer invoked"
  34. ;
  35. ;    Paint an initial window, using saved values
  36. ;
  37.    GOSUB Window             ; Open the window
  38.    GOSUB Get_Last            ; Get last Parm string
  39.    GOSUB Parse_Parm            ; Parse_Parms
  40.    GOSUB All_Fields            ; Display all fields
  41.  
  42.    LOCATE 7,8                ; Set cursor to 1st entry
  43. ;
  44. ;    Main-loop - look for keyentry
  45. ;
  46. Main_Loop:
  47.    SET TTHRU OFF            ; Disallow typeahead
  48.    KEYGET S0                ; Get a keystroke
  49. ;
  50. ;    Act upon the keystroke
  51. ;
  52. Have_Key:
  53.    SWITCH S0
  54.       CASE "4900"                       ; Pgup
  55.      GOTO PgUp
  56.       ENDCASE
  57.       CASE "5100"                       ; PgDn
  58.      GOTO PgDn
  59.       ENDCASE
  60.       CASE "4700"                       ; Home
  61.      GOTO Home
  62.       ENDCASE
  63.       CASE "4F00"                       ; End
  64.      GOTO End
  65.       ENDCASE
  66.       CASE "0D"                         ; C/r
  67.      GOTO Perform
  68.       ENDCASE
  69.       CASE "4800"                       ; Cursor up
  70.      GOTO UpLine
  71.       ENDCASE
  72.       CASE "5000"                       ; Cursor down
  73.      GOTO DnLine
  74.       ENDCASE
  75.       CASE "4B00"                       ; Cursor Left
  76.      GOTO Left
  77.       ENDCASE
  78.       CASE "4D00"                       ; Cursor right
  79.      GOTO Right
  80.       ENDCASE
  81.       CASE "09"                         ; Tab
  82.      GOTO Right
  83.       ENDCASE
  84.       CASE "0F00"                       ; Shift-tab
  85.      GOTO Left
  86.       ENDCASE
  87.    ENDSWITCH
  88. ;
  89. ;     Any other keystrokes must be ASCII keys
  90. ;
  91.    IF NOT NULL S0(1:3)
  92.       SOUND 100,100
  93.       GOTO Main_Loop
  94.       ENDIF
  95. ;
  96. ;     Decide where we are by the current cursor, and begin field entry
  97. ;
  98.    CURSOR N0,N1
  99.    IF GE N1 11
  100.       GOSUB Enter_DD            ; Enter dialing directory #
  101.       GOTO Have_Key            ; Return with a new keystroke
  102.    ELSE
  103.       GOSUB Enter_LD            ; Enter Long distance #
  104.       GOTO Right            ; Move to next field
  105.       ENDIF
  106. ;
  107. ; ----- Page up (cycle backwards through possible values)
  108. ;
  109. PgUp:
  110.    CURSOR N1,N2
  111.    IF GE N2 11
  112.       N0 = N10[N1-7]
  113.       N3 = N0/1000            ; Cycle DD#
  114.       N0 = N0-(N0/1000)*1000
  115.       N0 = N0-1
  116.       IF LT N0 0 N0 = 100
  117.       N0 = N0+N3*1000
  118.    ELSE
  119.       N0 = N10[N1-7]
  120.       N3 = N0-(N0/1000)*1000        ; Cycle LD#
  121.       N0 = N0/1000
  122.       N0 = N0-1
  123.       IF LT N0 0 N0 = 4
  124.       N0 = N3+N0*1000
  125.       ENDIF
  126. ;
  127. ;    Restore the value (N0, index N1) and display
  128. ;
  129.    N10[N1-7] = N0
  130.    GOSUB One_Field
  131.    GOTO Main_Loop
  132. ;
  133. ; ----- Page down (cycle forwards through possible values)
  134. ;
  135. PgDn:
  136.    CURSOR N1,N2
  137.    IF GE N2 11
  138.       N0 = N10[N1-7]
  139.       N3 = N0/1000            ; Cycle DD#
  140.       N0 = N0-(N0/1000)*1000
  141.       N0 = N0+1
  142.       IF GT N0 100 N0 = 0
  143.       N0 = N0+N3*1000
  144.       N10[N1-7] = N0
  145.       GOSUB One_Field
  146.    ELSE
  147.       N0 = N10[N1-7]
  148.       N3 = N0-(N0/1000)*1000        ; Cycle LD#
  149.       N0 = N0/1000
  150.       N0 = N0+1
  151.       IF GT N0 4 N0 = 0
  152.       N0 = N3+N0*1000
  153.       ENDIF
  154. ;
  155. ;    Restore the value (N0, index N1) and display
  156. ;
  157.    N10[N1-7] = N0
  158.    GOSUB One_Field
  159.    GOTO Main_Loop
  160. ;
  161. ; ----- Up a line
  162. ;
  163. UpLine:
  164.    CURSOR N0,N1
  165.    N0 = N0-1
  166.    IF LT N0 7 N0 = 16
  167.    N1 = 8                ; Set new start-of-field
  168.    IF GE N1 11 N1 = 11            ; Set new start-of-field
  169.    LOCATE N0,N1
  170.    GOTO Main_Loop
  171. ;
  172. ; ----- Down a line
  173. ;
  174. DnLine:
  175.    CURSOR N0,N1
  176.    N0 = N0+1
  177.    IF GT N0 16 N0 = 7
  178.    N1 = 8                ; Set new start-of-field
  179.    IF GE N1 11 N1 = 11
  180.    LOCATE N0,N1
  181.    GOTO Main_Loop
  182. ;
  183. ; ----- Home (move to first line)
  184. ;
  185. Home:
  186.    LOCATE 7,8
  187.    GOTO Main_Loop
  188. ;
  189. ; ----- End (Move to last line)
  190. ;
  191. End:
  192.    LOCATE 11,8
  193.    GOTO Main_Loop
  194. ;
  195. ; ----- Left (Next field)
  196. ;
  197. Left:
  198.    CURSOR N0,N1
  199.    IF GE N1 11
  200.       N1 = 8                ; Move to previous field
  201.    ELSE
  202.       N0 = N0-1             ; Move to previous line
  203.       N1 = 11
  204.       ENDIF
  205.    IF LT N0 7 N0 = 16            ; Last field
  206.    LOCATE N0,N1             ; And reposition cursor
  207.    GOTO Main_Loop
  208. ;
  209. ; ----- Right (Previous field)
  210. ;
  211. Right:
  212.    CURSOR N0,N1
  213.    IF GE N1 11
  214.       N0 = N0+1             ; Move to next row
  215.       N1 = 8
  216.    ELSE
  217.       N1 = 11                ; Move to next field
  218.       ENDIF
  219.    IF GT N0 16 N0 = 7            ; Last field
  220.    LOCATE N0,N1             ; And reposition cursor
  221.    GOTO Main_Loop
  222. ;
  223. ; ----- Subroutine Exit - terminate the process
  224. ;
  225. Exit:
  226.    RESTORE                ; Saved screen
  227.    LOCATE N8,N9             ; Restore cursor
  228.    EXIT
  229. ;
  230. ; ----- Subroutine: Enter a dialing directory #
  231. ;    .. on entry S0 -> The first keystroke
  232. ;    .. N1 within this subroutine is always current row#
  233. ;    .. S9 within this subroutine the field being constructed
  234. ;    .. N6 within this subroutine is an index to field being constructed
  235. ;
  236. Enter_DD:
  237.    CURSOR N1,N2             ; Get current row
  238.    N0 = N10[N1-7]
  239.    N0 = (N0/1000)*1000            ; Fake a 0 DD# with old LD#
  240.    GOSUB One_Field            ; Clear previous values on screen
  241.    N6 = 0                ; Index to field being built
  242.    S9 = ""                              ; Clear field
  243. ;
  244. ;    Look for an initial space or backspace (this 'blank's the field)
  245. ;
  246.    IF STRCMP S0 " "                     ; If enter with space
  247.       N10[N1-7] = N0
  248.       GOTO DD_Keypress            ; Start w/new key
  249.       ENDIF
  250.    IF STRCMP S0 "08"                    ; If enter with backspace
  251.       N10[N1-7] = N0
  252.       GOTO DD_Keypress            ; Start w/new key
  253.       ENDIF
  254. ;
  255. ;    The space bar terminates data entry
  256. ;
  257. DD_Test:
  258.    IF STRCMP S0 " "                     ; If space key
  259.       S0 = "4D00"                       ; Fake a cursor right
  260.       GOTO DD_Store            ; End of routine
  261.       ENDIF
  262. ;
  263. ;    A "?" pops up the dialing directory
  264. ;
  265.    IF STRCMP S0 "?"                     ; If enter with backspace
  266.       GOSUB Ask_Dial            ; Display dialing directory
  267.       IF SUCCESS            ; If an entry selected..
  268.      S9 = S2            ; Move to accumulator string
  269.      LENGTH S9 N6            ; Length of entry
  270.      S0 = "4D00"                    ; Fake a cursor right
  271.      GOTO DD_Store            ; ANd use it
  272.      ENDIF
  273.       GOTO DD_Keypress            ; Else start over
  274.       ENDIF
  275. ;
  276. ;    Look for special chars (tab, and backspace, and non-ASCII)
  277. ;
  278.    SWITCH S0
  279.       CASE "09"                         ; Tab key
  280.      GOTO DD_Store
  281.       ENDCASE
  282.       CASE "0D"                         ; Carriage rtn end field here
  283.      S0 = "4D00"                    ; Fake a cursor right
  284.      GOTO DD_Store
  285.       ENDCASE
  286.       CASE "08"                         ; Backspace
  287.      IF GT N6 0            ; If anything entered
  288.         CURSOR N1,N2
  289.         N2 = N2-1
  290.         LOCATE N1,N2
  291.         ATSAY  N1,N2 (default) " "
  292.         S1(N6:N6) = " "
  293.         N6 = N6-1
  294.         ENDIF
  295.      GOTO DD_Keypress        ; And go for another key
  296.       ENDCASE
  297.    ENDSWITCH
  298.    IF NOT NULL S0(1:3) GOTO DD_Store    ; Not ascii key
  299. ;
  300. ;    Filter only numeric chars here
  301. ;
  302.    CTOI S0 N0                ; Easier comparison
  303.    IF LT N0 48 GOTO DD_Invalid        ; 48 = '0'
  304.    IF GT N0 57 GOTO DD_Invalid        ; 56 = '9'
  305. ;
  306. ;    Add the character to our field being constructed
  307. ;
  308.    S9(N6:N6) = S0            ; Add the char
  309.    N6 = N6+1
  310. ;
  311. ;    Display the keystroke in S0
  312. ;
  313.    CURSOR N1,N2
  314.    ATSAY N1,N2 (d